<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileMoveDir</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileMoveDir</h1>

<p>Moves a folder along with all its sub-folders and files. It can also rename a folder.</p>

<pre class="Syntax">FileMoveDir, Source, Dest [, Flag]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Source</dt>
  <dd><p>Name of the source directory (with no trailing backslash), which is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. For example: C:\My Folder</p></dd>

  <dt>Dest</dt>
  <dd><p>The new path and name of the directory (with no trailing baskslash), which is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified. For example: D:\My Folder. <strong>Note</strong>: <em>Dest</em> is the actual path and name that the directory will have after it is moved; it is <em>not</em> the directory into which <em>Source</em> is moved (except for the known limitation mentioned below).</p></dd>

  <dt>Flag</dt>
  <dd><p>(options) Specify one of the following single characters:</p>
      <p><strong>0</strong> (default): Do not overwrite existing files. The operation will fail if <em>Dest</em> already exists as a file or directory.</p>
      <p><strong>1</strong>: Overwrite existing files. However, any files or subfolders inside <em>Dest</em> that do not have a counterpart in <em>Source</em> will not be deleted. <strong>Known limitation:</strong> If <em>Dest</em> already exists as a folder and it is on the same volume as <em>Source</em>, <em>Source</em> will be moved into it rather than overwriting it. To avoid this, see the next option.</p>
      <p><strong>2</strong>: The same as mode 1 above except that the limitation is absent.</p>      
      <p><strong>R</strong>: Rename the directory rather than moving it. Although renaming normally has the same effect as moving, it is helpful in cases where you want &quot;all or none&quot; behavior; that is, when you don't want the operation to be only partially successful when <em>Source</em> or one of its files is locked (in use). Although this method cannot move <em>Source</em> onto a different volume, it can move it to any other directory on its own volume. The operation will fail if <em>Dest</em> already exists as a file or directory.</p></dd>

</dl>

<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to 1 if there was a problem or 0 otherwise.</p>
<h3>Remarks</h3>
<p>FileMoveDir moves a single folder to a new location. To instead move the contents of a folder (all its files and subfolders), see the examples section of <a href="FileMove.htm">FileMove</a>.</p>
<p>If the source and destination are on different volumes or UNC paths, a copy/delete operation will be performed rather than a move.</p>
<h3>Related</h3>
<p><a href="FileCopyDir.htm">FileCopyDir</a>, <a href="FileCopy.htm">FileCopy</a>, <a href="FileMove.htm">FileMove</a>, <a href="FileDelete.htm">FileDelete</a>, <a href="LoopFile.htm">File-loops</a>, <a href="FileSelectFolder.htm">FileSelectFolder</a>, <a href="SplitPath.htm">SplitPath</a></p>
<h3>Example</h3>
<pre class="NoIndent">FileMoveDir, C:\My Folder, D:\My Folder  <em>; Move to a new drive.</em>
FileMoveDir, C:\My Folder, C:\My Folder (renamed), R  <em>; Simple rename.</em>
FileMoveDir, C:\My Folder, C:\New Location\My Folder, R  <em>; Folders can be &quot;renamed into&quot; another location as long as it's on the same volume.</em></pre>

</body>
</html>
